package com.home766.controller.shop;

import com.home766.entity.Appointment;
import com.home766.service.AppointmentService;
import net.biz.Message;
import net.biz.controller.shop.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

@Controller("appointmentShopController")
@RequestMapping("/shop/appointment")
public class AppointmentController extends BaseController {
	@Resource(name="appointmentServiceImpl")
	private AppointmentService appointmentService;
	/***
	 * 新增预约
	 * @param appointment
	 */
	@RequestMapping("/add")
	@ResponseBody
	public Message add(Appointment appointment){
		Message msg = new Message();
		try {
			appointment.setAppointment(new Date());
			appointment.setHandle(0);
			appointmentService.save(appointment);
			msg.setContent("恭喜您!订单已预约成功,766工作人员将会及时与您联系!");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			msg.setContent("预约失败");
		}
		return msg;
	}
}
